package com.hyg.module_report.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hyg.module_report.R;
import com.hyg.module_report.databinding.ItemExplainAdapterV2Binding;
import com.hyg.module_report.model.PulseAnalyze;

import java.util.List;

/**
 * @author: Administrator
 * @date: 2020/12/31
 */
public class InfoExplainAdapter extends  RecyclerView.Adapter<InfoExplainAdapter.ExplainHolder>{
        ItemExplainAdapterV2Binding binding;
        List<PulseAnalyze> list;

    public InfoExplainAdapter( List<PulseAnalyze> list) {
        this.list=list;
    }

    @NonNull
    @Override
    public ExplainHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_explain_adapter_v2, parent, false);
        ExplainHolder holder = new ExplainHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ExplainHolder holder, int position) {
        if(binding==null){
            return;
        }
        binding.tvName.setText(list.get(position).getName());
        binding.tvExplain.setText("\u3000\u3000"+list.get(position).getAnalyze());
    }

    @Override
    public int getItemCount() {
        if(list==null){
            return 0;
        }else{
            return list.size();
        }
    }


    public class ExplainHolder extends RecyclerView.ViewHolder {
        public ExplainHolder(@NonNull View itemView) {
            super(itemView);
            binding=ItemExplainAdapterV2Binding.bind(itemView);
        }
    }

}
